package org.hagopa.games.moneypool.msgs;

public enum CommandsEnum {
	//Handshake commands
	SERV_HELLO	        (100, "ServerHello",         1),
	INTRO		        (120, "ClientIntro",         2),
	ACCEPT		        (130, "Accept",              1),
	DENY                    (140, "Deny",                1),
	READY		        (160, "Ready",               2),
        JOIN_RESPONSE	        (165, "JoinResponse",        1),
        START_GAME              (170, "StartGame",           2),
	UPDATE		        (180, "Update",              1),
	////
	PLAY                    (181,  "Play",               3),
	UPD_PLAYER              (182,  "PlayerUpdate",       3),
	WAIT_ACTIVE_PLAYER      (183,  "WaitForActivePLayer",3),
	DIES_RESULT             (184,  "DiesThrowResult",    3),
	////
	
	//Game Commands
	
	THR_DIES                (400, "ThrowDies",           2),
	MOVE_DONE               (420, "MoveDone",            2),
	AC_NONE                 (430, "NoAction",            2),
	AC_PAY                  (440, "PayAction",           2),
	AC_BUY                  (450, "BuyAction",           2),
        AC_EXCHANGE             (451, "ExchangePlayers",     2),
        AC_PARTNER              (452, "AC_PARTNER",          2),
	AC_SELL                 (460, "SellAction",          2),
	AC_MORTGAGE             (470, "Morgage",             2),
	AC_UPGRADE              (480, "Upgrade",             2),
        GET_QUEST               (500, "Req4Quest",           2),
	END_TURN                (555, "EndTurn",             2),
	// End Game Commands 
	//Chat Commands
        NG_AC_BUY               (600, "Request4BuyAction",   1),
        NG_AC_EXCHANGE          (610, "Request4Exchange",    1),
        NG_AC_PATNER            (620, "Request4Partnership", 1),
        NG_AC_SELL              (630, "Request4SellAction",  1),
	CHAT_MSG                (150, "ChatMsg",             2),
        SERV_BROADCAST          (155, "ServBroadcastMsg",    1),
	//BCHAT_MSG   (150, "BCChatMsg",    1),
	//--------------------------

        RESIGN                  (998, "resign from being Active player", 2),
	DISCONNECT              (999, "Disconnect",          2)
	;
	private int idx;
	private String name = null;
	private int type;
	
	CommandsEnum(int ind, String name, int type)
	{
		this.idx = ind;
		this.name = name;
		this.type = type;
	}
	public static CommandsEnum getEnum(int idx)
	{
		switch (idx){
		case 100:
			return SERV_HELLO;
		case 120:
			return INTRO;
		case 130:
			return ACCEPT;
		case 140:
			return DENY;
//		case 150:
//			return BCHAT_MSG;
		case 160:
			return READY;
                case 165:
                        return JOIN_RESPONSE;
                case 170:
                        return START_GAME;
		case 150:
			return CHAT_MSG;
                case 155:
                        return SERV_BROADCAST;
		case 180:
			return UPDATE;
                case 181:
                        return PLAY;
                case 182:
                        return UPD_PLAYER;
                case 183:
                        return WAIT_ACTIVE_PLAYER;
                case 184:
                        return DIES_RESULT;
                case 400:
			return THR_DIES;
		case 420:
			return MOVE_DONE;
		case 430:
			return AC_NONE;
		case 440:
			return AC_PAY;
		case 450:
			return AC_BUY;
                case 451:
                        return AC_EXCHANGE;
                case 452:
                        return AC_PARTNER;
		case 460:
			return AC_SELL;
		case 470:
			return AC_MORTGAGE;
		case 480:
			return AC_UPGRADE;
                case 500:
                        return GET_QUEST;
		case 555:
			return END_TURN;
                case 600:
                        return NG_AC_BUY;
                case 610:
                        return NG_AC_EXCHANGE;
                case 620:
                        return NG_AC_PATNER;
                case 630:
                        return NG_AC_SELL;
                case 998:
                        return RESIGN;
		case 999:
			return DISCONNECT;
			default:
				return null;
		}
		
	}
	public int idx()
	{
		return this.idx;
	}
	public String getName()
	{
		return this.name;
	}
	public int getType()
	{
		return this.type;
	}
	public boolean isFromClient()
	{
		if(this.type == 2 )
			return true;
		else
			return false;
	}
}
